package com.netty.websocket;

import com.alibaba.fastjson.JSONObject;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;

import java.util.concurrent.ConcurrentHashMap;

public abstract class BaseChannelGroup  {
    public ConcurrentHashMap<String,Integer> mapQueueSize =new ConcurrentHashMap();//记录所有队列的SingleQueue
    public String queue=null;

    public abstract BaseChannelGroup add(NettySession nettySession);
    public abstract BaseChannelGroup remove(NettySession nettySession);
    public abstract boolean writeAndFlush(NettySession nettySession,String recvQueue,JSONObject msgJSON);
    public abstract boolean writeAndFlush(NettySession nettySession,String recvQueue,WebSocketFrame textMessage);
    public boolean writeAndFlush2(NettySession nettySession,String recvQueue,WebSocketFrame textMessage){
        return false;
    }

    //public abstract int size();

    public final int size(){
        if(queue==null) return 0;
        Integer size=mapQueueSize.get(queue);
        return size==null?0:size;
    }
}
